/*
 *  权限插件
 */
import { useUserStore } from '@/store/modules/system/user';
import { App } from 'vue'

const privilege = (value: string) => {
  // 超级管理员
  if (useUserStore().userInfo.administratorFlag) {
    return true;
  }
  // 获取功能点权限
  let userPointsList = useUserStore().getPointList as string[];
  if (!userPointsList) {
    return false;
  }
  return userPointsList &&  userPointsList?.includes(value);
};

export default {
  install: (app: App): void => {
    app.config.globalProperties.$privilege = privilege;
  },
};
